package com.gee.spring.boot.rpf.controller;


import com.gee.spring.boot.rpf.config.cache.ClientCacheConfig;
import org.springframework.web.bind.annotation.RestController;
import com.gee.spring.boot.rpf.util.result.Result;
import com.gee.spring.boot.rpf.util.result.ResultCode;
import com.gee.spring.boot.rpf.util.result.ResultUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import com.gee.spring.boot.rpf.service.RefClientFlowTempVariableInfoService;
import com.gee.spring.boot.rpf.entity.RefClientFlowTempVariableInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author gee
 * @since 2021-02-13
 */
@RestController
@RequestMapping("/rpf/refClientFlowTempVariableInfo")
public class RefClientFlowTempVariableInfoController {
    private final Logger logger = LoggerFactory.getLogger(RefClientFlowTempVariableInfoController.class);

    @Autowired
    public RefClientFlowTempVariableInfoService refClientFlowTempVariableInfoService;

    @Autowired
    private ClientCacheConfig clientCacheConfig;

    @GetMapping("/getById/{id}")
    public Result getById(@PathVariable("id") String id){
            RefClientFlowTempVariableInfo refClientFlowTempVariableInfo = refClientFlowTempVariableInfoService.getById(id);
            if (refClientFlowTempVariableInfo == null){
                return ResultUtil.error(ResultCode.NULL_DATA);
            }
            return ResultUtil.successWithData(refClientFlowTempVariableInfo);
    }

    @GetMapping("/refreshCache")
    public Result refreshCache(){
        clientCacheConfig.initRefClientFlowTempVariableInfoCache();
        return ResultUtil.success();
    }

}